package com.bwf.file;

import java.io.File;
import java.io.IOException;

/**
 * @Version v1.0
 * @Description: TODO
 * @Author ZHANZHONGXIN
 * @Date 2022/5/18 11:02
 * @Copyright 博为峰
 */
public class FileDemo {
    public static void main(String[] args) throws IOException {
//        m1();
//        m2();
//        m3();
        File file = new File("D:\\works22\\java22");
        String[] list = file.list();
        for (String s : list) {
//            System.out.println(s);
        }

        File[] listFiles = file.listFiles(new FilenameFilterImpl(""));
        for (File f : listFiles) {
//            if (f.getName().equals("JAVA.md")) {
                System.out.println(f.getName());
//            }

//            if(f.getName().endsWith("png")){
//                System.out.println(f.getName());
//            }
        }
    }

    private static void m3() {
        File file = new File("C:\\Users\\admin\\Desktop\\io\\a");
//        file.mkdir();//创建单级目录
//        file.mkdirs();//多级目录
//        file.createNewFile();//创建文件
        System.out.println(file.delete());
    }

    private static void m2() {
        final File file = new File("D:\\works22\\java22\\JAVA.md");
        System.out.println(file.getName());//文件名
        System.out.println(file.getPath());//文件路径
        System.out.println(file.lastModified());//修改时间
        System.out.println(file.length());//文件大小（字节）
    }

    private static void m1() {
        final File file = new File("D:\\works22\\java22\\JAVA.md");

        final File file2 = new File("D:" + File.separator + "works22\\java22\\JAVA.md");

        final File dir = new File("D:\\works22\\java22\\");

        final File f = new File(dir, "JAVA.md");
    }
}
